package com.explgo.backend.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.explgo.backend.domain.Category;
import com.explgo.backend.domain.NileguideResponse;
import com.explgo.backend.domain.Place;
import com.explgo.backend.domain.Plan;
import com.explgo.backend.service.NileguideService;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

public class NileguideServiceImpl implements NileguideService {
	private static String nileguideKey = new String("f9a33a25-8ea0-4f14-82f5-057256b23aa2");
	private static String basePlaceURL = new String("http://www.nileguide.com/service/place/");
	private static String baseNeighborhoodURL = new String("http://www.nileguide.com/service/neighborhood/");
	
	@Override
	public ArrayList<Place> requestInfo(long cityId){
		RestTemplate temp = new RestTemplate();
	    List<MediaType> mediaTypes = new ArrayList<MediaType>();
	    mediaTypes.add(MediaType.APPLICATION_JSON);
	    HttpHeaders headers = new HttpHeaders();
	    headers.setAccept(mediaTypes);
	    
	    NileguideResponse ngResponse = new NileguideResponse();
		HttpEntity<NileguideResponse> httpEntity = new HttpEntity<NileguideResponse>(ngResponse,headers);

		String placeURL = basePlaceURL+"?key="+nileguideKey+"&searchTerms=destinationId:"+cityId;
		ResponseEntity<NileguideResponse> entity = temp.exchange(placeURL, HttpMethod.GET, httpEntity, NileguideResponse.class);
//		Place[] places = entity.getBody();
		System.out.println("This is:\n"+entity);
		return null;
	}

	@Override
	public ArrayList<Place> requestInfo(long cityId, Category category) {
		// TODO Auto-generated method stub
		return null;
	}

}
